import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class VelocityTest {
    public static void main(String[] args) throws IOException {
        Map<String, Object> OldHead = new HashMap<>();
        OldHead.put("taskName", "跑批");
        OldHead.put("date", "20211110");
        OldHead.put("bankName", "民生");
        OldHead.put("pageSize", "1");

        List<Map<String, Object>> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {

            Map<String, Object> map = new HashMap<>();
            map.put("recNbr", "11:" + i);
            map.put("option", "I");
            map.put("custrNbr", "424242");
            map.put("cardNbr", "00088888");
            map.put("addType", "银行");
            list.add(map);
        }
        //头数据处理
        Map<String, Object> newHead = new HashMap<>();
        //设计指定长度，对齐格式
        StringAlign formatter = new StringAlign(10, StringAlign.JUST_RIGHT);
        //取出每个数据进行指定长度设置
        for (Map.Entry<String, Object> entry : OldHead.entrySet()) {
            String headData = formatter.format(entry.getValue().toString());
            newHead.put(entry.getKey(), headData);
        }
        //体数据处理
        List<Map<String, Object>> bodyList = new ArrayList<>();
        formatter = new StringAlign(20, StringAlign.JUST_CENTER);

        for (int j = 0; j < list.size(); j++) {
            Map<String, Object> newBody = new HashMap<>();
            Map<String, Object> bodyMap = list.get(j);
            for (Map.Entry<String, Object> entry : bodyMap.entrySet()) {
                String bodyData = formatter.format(entry.getValue().toString());
                newBody.put(entry.getKey(), bodyData);
            }
            bodyList.add(newBody);
        }

        List<List<Map<String, Object>>> paging = VelocityUtils.paging(bodyList, 10);
        VelocityUtils.velocityTemplate(newHead, paging);
    }
}
